package tool;

import java.sql.*;

public class jdbctool {
    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getconection()throws SQLException
    {
        return DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/servlet?serverTimezone=UTC&useSSL=false",
                "root",
                "11111");
    }
    public static void close(Connection connection, PreparedStatement statement, ResultSet rs){
        if (rs!=null) {
            try {
                rs.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if(statement!=null) {
            try {
                statement.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if(connection!=null) {
            try {
                connection.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
}
